package org.meal.service.impl;

import cn.meal.entity.Store;
import cn.meal.mapper.StoreMapper;
import cn.meal.vo.StoreListVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.meal.service.StoreService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {


    @Override
    public List<StoreListVo> getStoreByMerchantId(Integer merchantId) {
        QueryWrapper<Store> wrapper=new QueryWrapper<>();
        wrapper.eq("merchant_id",merchantId);
        List<Store> stores=baseMapper.selectList(wrapper);
        List<StoreListVo> list=new ArrayList<>();
        if(!stores.isEmpty()){
            for(Store store:stores){
                StoreListVo storeListVo=new StoreListVo();
                BeanUtils.copyProperties(store,storeListVo);
                list.add(storeListVo);
            }
        }
        return list;
    }
}
